import threading
import time


# https://www.cnblogs.com/cnkai/p/7504980.html

def run():
    time.sleep(1)
    print('当前线程的名称是: %s' % (threading.currentThread().name))
    time.sleep(1)


if __name__ == '__main__':
    start_time = time.time()
    print('这是主线程: %s' % threading.currentThread().name)

    threads = []
    for i in range(5):
        t = threading.Thread(target=run)
        threads.append(t)

    for t in threads:
        # t.setDaemon(True)
        t.start()

    for t in threads:
        t.join()

    print('主线程结束!', threading.currentThread().name)
    print('一共用时: ', time.time() - start_time)
